package com.ucs.ui;

import java.util.TimerTask;


//import android.util.Log;

import com.ucs.domain.Order;
import com.ucs.util.UCSData;
import com.ucs.util.UCSUtil;

public class SubmitPendingOrderTask extends TimerTask {
	private Order theOrder;
	
	@Override
	public void run() {
//		Log.d("ucs", "+SubmitPendingOrderTask:run");
		if (theOrder == null){
			theOrder = UCSData.getInstance().peekPendingOrder(0);
			if (theOrder != null){
				theOrder.setSend(1);
			}
		}
		if (theOrder == null){
			return;
		}
		if (UCSUtil.postOrder(theOrder)) {
			theOrder = null;
			UCSData.getInstance().removePendingOrder(0);
		}
		else{
			theOrder.setSend(0);
		}
//		Log.d("ucs", "-SubmitPendingOrderTask:run");
	}
}
